package com.liuluo.homework1025hou.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuluo.homework1025hou.domain.Student;
import com.liuluo.homework1025hou.service.StudentService;
import com.liuluo.homework1025hou.mapper.StudentMapper;
import org.springframework.stereotype.Service;

/**
* @author liulu
* @description 针对表【student】的数据库操作Service实现
* @createDate 2025-02-24 09:58:46
*/
@Service
class StudentServiceImpl(private val studentMapper: StudentMapper) : ServiceImpl<StudentMapper, Student>(), StudentService {
    override fun getAll(): List<Student> {
        return studentMapper.getAllStudents()
    }

    override fun add(student: Student): Int {
        return studentMapper.addStudent(student)
    }

    override fun delete(id:Int): Int {
        return studentMapper.deleteStudentById(id)
    }

    override fun update(student: Student): Int {
        return studentMapper.updateStudent(student)
    }

    override fun getOneById(id: Int): List<Student> {
        return studentMapper.getStudentById(id)
    }

    override fun getOneByName(name: String): List<Student> {
        return studentMapper.getStudentByUserName(name)
    }

    override fun selectByCondition(id: Int, name: String): List<Student> {
        val queryWrapper = QueryWrapper<Student>()
        queryWrapper.eq("name",name).or().eq("id",id)
        return baseMapper.selectList(queryWrapper)
    }




}




